{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "495f65c3",
   "metadata": {},
   "source": [
    "### 支持的模型名称\n",
    "\n",
    "模型名称替换代码中的 `model_name`变量的值。\n",
    "\n",
    "| **模型系列** | **模型名称**                                                 |\n",
    "| ------------ | ------------------------------------------------------------ |\n",
    "| ResNet       | resnet18, resnet34, resnet50, resnet101, resnet152, resnext50_32x4d, resnext101_32x8d, wide_resnet50_2, wide_resnet101_2 |\n",
    "| 敬请期待       | 以下暂未支持 |\n",
    "| AlexNet      | alexnet                                                      |\n",
    "| VGG          | vgg11, vgg11_bn, vgg13, vgg13_bn, vgg16, vgg16_bn, vgg19_bn, vgg19 |\n",
    "| DenseNet     | densenet121, densenet169, densenet201, densenet161           |\n",
    "| Inception    | googlenet, inception_v3                                      |\n",
    "| SqueezeNet   | squeezenet1_0, squeezenet1_1                                 |\n",
    "| ShuffleNetV2 | shufflenet_v2_x2_0, shufflenet_v2_x0_5, shufflenet_v2_x1_0, shufflenet_v2_x1_5 |\n",
    "| MobileNet    | mobilenet_v2, mobilenet_v3_large, mobilenet_v3_small         |\n",
    "| MNASNet      | mnasnet0_5, mnasnet0_75, mnasnet1_0, mnasnet1_3              |\n",
    "| ViT       | ViT, SimpleViT, CrossFormer, S|\n",
    "\n",
    "![](http://medai.icu/storage/attachments/2023/10/10/RHd9eH5U67VsOP8vqyNyBD5nGYREejkAKx3Jw16X.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7050436a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from onekey_algo.end2end.run_OnekeyNet import main as onekey_main\n",
    "from collections import namedtuple\n",
    "\n",
    "# 设置参数\n",
    "input_settings = {\n",
    "    'A': {\n",
    "        'data_pattern': r'C:\\Users\\onekey\\Desktop\\onekey\\crop',\n",
    "        'image_type': '2d', 'model_name': 'resnet18', 'encoder': 'cnn'},\n",
    "    'P': {\n",
    "        'data_pattern': r'C:\\Users\\onekey\\Desktop\\onekey\\crop',\n",
    "        'image_type': '2d', 'model_name': 'resnet101', 'encoder': 'cnn'},\n",
    "    'V': {\n",
    "        'data_pattern': r'C:\\Users\\onekey\\Desktop\\onekey\\crop',\n",
    "        'image_type': '2d', 'model_name': 'resnet50', 'encoder': 'cnn'},\n",
    "    'clinic': {\n",
    "        'feature_file': r'C:\\Users\\onekey\\Desktop\\onekey\\features/clinical.csv', 'norm': True,\n",
    "        'input_dim': 8, 'hidden_unit': [32, 64, 128, 32], 'dropout': 0.5, 'encoder': 'dnn'},\n",
    "    'radiomics': {\n",
    "        'feature_file': r'C:\\Users\\onekey\\Desktop\\onekey\\features\\pre/rad_features_intra.csv', 'norm': True,\n",
    "        'input_dim': 107, 'hidden_unit': [32, 64, 128, 32], 'dropout': 0.5, 'encoder': 'dnn'}\n",
    "}\n",
    "\n",
    "task_settings = {\n",
    "    'pCR': {'label_file': r'C:\\Users\\onekey\\Desktop\\onekey\\task/pCR.csv',\n",
    "            'type': 'clf', 'num_classes': 2},\n",
    "    'OS': {'label_file': r'C:\\Users\\onekey\\Desktop\\onekey\\task/OS.csv',\n",
    "           'type': 'sur', 'event_column': 'event', 'duration_column': 'duration'},\n",
    "    'AgeEst': {'label_file': r'C:\\Users\\onekey\\Desktop\\onekey\\task/brain_age.csv',\n",
    "               'type': 'reg'}}\n",
    "\n",
    "# 融合的设置,fusion_settings融合DNN\n",
    "fusion_settings = {'hidden_unit': [16, 32, 16], 'dropout': 0.1}\n",
    "# 如果非None，则使用Transformer否则使用fusion DNN模型\n",
    "trans_dim = 64\n",
    "# 模型存放的位置\n",
    "model_root = r'C:\\Users\\onekey\\Desktop\\onekey/models'\n",
    "\n",
    "params = dict(input_settings=input_settings,\n",
    "              task_settings=task_settings,\n",
    "              fusion_settings=fusion_settings,\n",
    "              trans_dim=trans_dim,\n",
    "              batch_size=32,\n",
    "              epochs=8,\n",
    "              init_lr=0.0001,\n",
    "              optimizer='sgd',\n",
    "              retrain=r'',\n",
    "              model_root=model_root,\n",
    "              add_date=False,\n",
    "              iters_start=0,\n",
    "              iters_verbose=1,\n",
    "              save_per_epoch=True)\n",
    "# 训练模型\n",
    "Args = namedtuple(\"Args\", params)\n",
    "onekey_main(Args(**params))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ce1f8dc1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
